package com.service.Impl;

import com.dao.ProviderDao;
import com.pojo.Provider;
import com.service.ProviderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProviderServiceImpl implements ProviderService {
    @Autowired
    private ProviderDao providerDao;

    public boolean doAddProviderService(Provider provider) {
        int row = providerDao.addProviderDao(provider);
        if (row>0){
            return true;
        }else {
            return false;
        }
    }

    public boolean doDeleteProviderService(int id) {
        int row = providerDao.deleteProviderDao(id);
        if (row>0){
            return true;
        }else {
            return false;
        }
    }

    public boolean doUpdateProviderService(Provider provider) {
        int row = providerDao.updateProviderDao(provider);
        if (row>0){
            return true;
        }else {
            return false;
        }
    }

    public Provider findProviderById(int id) {
        return providerDao.findProviderById(id);
    }

    public List<Provider> findAll() {
        return providerDao.findAll();
    }

    @Override
    public List<Provider> findSearchProvider(String proName) {
        return providerDao.searchProvider(proName);
    }
}
